<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var reg = /\d{3}/g
        /* 
            获取字符串当中一段字符串片段,但是只能获取第一段片段,如果我要获取多段片段
            所以我们需要借助与一个 标识符 g

            1. 先获取第一个匹配的正则
            2. 再往后获取一个匹配的正则,如果获取不到,那么返回是null
            3. 如果是null,再往后获取,那么将是从头开始获取
        */
        console.log(reg.exec("abc123def456"));
        console.log(reg.exec("abc123def456"));
        console.log(reg.exec("abc123def456"));
        console.log(reg.exec("abc123def456"));
    </script>
</body>
</html>